<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>es6实现继承</title>
</head>
<body>
    <script>
        class Person
        {
             constructor(name,age,height)
             {
                this._name = name;
                this._age = age;
                this._height = height;
             }

             running()
             {
               
                 console.log("running");
             }

             eat()
             {
                console.log("eat");
             }
        }

        class Student extends Person
        {
            constructor(name,age,height,id,grates)
            {
                //使用super函数调用父类的构造
                super(name,age,height);
                //子类自己的构造
                this._grades = grates;
                this._id = id;
            }

            running()
            {
                  super.running();
                  console.log(this._name+" running");
            }
        }
        
        var stu = new Student("cq",18,1.88,12345,100);
        console.log(stu._name);
        console.log(stu._age);
        console.log(stu._height);
        console.log(stu._id);
        console.log(stu._grades);
        stu.running();
        stu.eat();

    </script>
</body>
</html>